import { defineStore } from 'pinia'
import { type Object3D } from 'three'
import { ref, shallowRef } from 'vue'

export type ActiveFilter = 'person' |
  'baseStation' |
  'sensor' |
  'camera' |
  'workArea'

export const useActiveObject = defineStore('activeObject', () => {
  const activeVO = ref<Object3D>()
  const activeShallowRef = shallowRef<Object3D>()

  function setActiveVO (obj: Object3D | undefined) {
    activeVO.value = obj
    activeShallowRef.value = obj
  }

  const activeFilter = ref<ActiveFilter[]>(['workArea'])
  const isHistoryTracking = ref(false)

  function setActiveFilter (filter: ActiveFilter[]) {
    activeFilter.value = filter
  }

  function setIsHistoryTracking (isTracking: boolean) {
    isHistoryTracking.value = isTracking
  }

  return { activeVO, activeShallowRef, setActiveVO, activeFilter, setActiveFilter, isHistoryTracking, setIsHistoryTracking }
})
